/*    */ package com.controller.front;
/*    */ 
/*    */ import base.utils.ResultUtil;
/*    */ import com.model.Contact;
/*    */ import com.service.ContactService;
/*    */ import java.util.Date;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.servlet.ModelAndView;
/*    */ import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"contact"})
/*    */ public class ContactController
/*    */ {
/* 32 */   protected Logger log = Logger.getLogger(ContactController.class);
/*    */   
/*    */ 
/*    */ 
/*    */   @Autowired
/*    */   private ContactService contactService;
/*    */   
/*    */ 
/*    */ 
/*    */   @RequestMapping({"addEvent"})
/*    */   public ModelAndView addEvent(HttpServletRequest request)
/*    */   {
/* 44 */     ModelAndView mv = new ModelAndView();
/* 45 */     Map<String, Object> attributes = new HashMap();
/* 46 */     MappingJacksonJsonView view = new MappingJacksonJsonView();
/*    */     try {
/* 48 */       String name = request.getParameter("name");
/* 49 */       String email = request.getParameter("email");
/* 50 */       String message = request.getParameter("message");
/*    */       
/* 52 */       if (("".equals(name)) || (name == null)) {
/* 53 */         Map<String, Object> map = new HashMap();
/* 54 */         return ResultUtil.returnJsonStr("1", "name参数为空", attributes, map, view, mv);
/*    */       }
/* 56 */       if (("".equals(email)) || (email == null)) {
/* 57 */         Map<String, Object> map = new HashMap();
/* 58 */         return ResultUtil.returnJsonStr("1", "email参数为空", attributes, map, view, mv);
/*    */       }
/* 60 */       if (("".equals(message)) || (message == null)) {
/* 61 */         Map<String, Object> map = new HashMap();
/* 62 */         return ResultUtil.returnJsonStr("1", "message参数为空", attributes, map, view, mv);
/*    */       }
/*    */       
/*    */ 
/*    */ 
/*    */ 
/* 68 */       Contact contact = new Contact();
/* 69 */       contact.setName(name);
/* 70 */       contact.setEmail(email);
/* 71 */       contact.setMessage(message);
/* 72 */       contact.setCreateTime(new Date());
/* 73 */       contact.setDeleteFlag(0);
/* 74 */       int insertByEntity = this.contactService.insertByEntity(contact);
/* 75 */       this.log.info("ContactController addEvent  insertByEntity  " + insertByEntity);
/* 76 */       Map<String, Object> map = new HashMap();
/* 77 */       return ResultUtil.returnJsonStr("0", "提交成功", attributes, map, view, mv);
/*    */     }
/*    */     catch (Exception e)
/*    */     {
/* 81 */       e.printStackTrace();
/* 82 */       Map<String, Object> map = new HashMap();
/* 83 */       return ResultUtil.returnJsonStr("1", "系统错误", attributes, map, view, mv);
/*    */     }
/*    */   }
/*    */ }


/* Location:              C:\Users\chengkp\Desktop\interwar\WEB-INF\classes\!\com\controller\front\ContactController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */